package com.xdtech.sys.vo;

import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.sys.model.MenuFunction;

public class MenuItem {
	
	private Long pMenuId;
	
	private String pMenuName;
	
	private Long id;
	
	private String nameCN;
	
	private String pageUrl;
	
	private String iconName;
	
	private String operationCode;
	
	private Boolean iframe;
	
	private Boolean enabled;//菜单是否可用,0不可用，1可用

	public Long getpMenuId() {
		return pMenuId;
	}

	public void setpMenuId(Long pMenuId) {
		this.pMenuId = pMenuId;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNameCN() {
		return nameCN;
	}

	public void setNameCN(String nameCN) {
		this.nameCN = nameCN;
	}

	public String getPageUrl() {
		return pageUrl;
	}

	public void setPageUrl(String pageUrl) {
		this.pageUrl = pageUrl;
	}

	public String getIconName() {
		return iconName;
	}

	public void setIconName(String iconName) {
		this.iconName = iconName;
	}

	public String getpMenuName() {
		return pMenuName;
	}

	public void setpMenuName(String pMenuName) {
		this.pMenuName = pMenuName;
	}

	public String getOperationCode() {
		return operationCode;
	}

	public void setOperationCode(String operationCode) {
		this.operationCode = operationCode;
	}

	public Boolean getIframe()
	{
		return iframe;
	}

	public void setIframe(Boolean iframe)
	{
		this.iframe = iframe;
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public void setEnabled(Boolean enabled) {
		//兼容旧代码，之前enabled属性没启用，默认都是空的
		this.enabled = (enabled==null||enabled)?true:false;
	}

	public static MenuItem createItem(MenuFunction mf) {
		if (mf==null) {
			return null;
		}else {
			MenuItem menuItem = new MenuItem();
			BeanUtils.copyProperties(menuItem, mf);
			MenuFunction pmf = mf.getParent();
			if (pmf!=null) {
				menuItem.setpMenuId(pmf.getId());
				menuItem.setpMenuName(pmf.getNameCN());
			}
			return menuItem;
		}
	}
}
